﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace KeyboardImageViewer
{
    /// <summary>
    /// Interaction logic for EditMultipleTags.xaml
    /// </summary>
    public partial class EditMultipleTags : Window
    {
        private TagAutoCompleteTextBox tagBox;

        public EditMultipleTags(MainWindow window)
        {
            this.Owner = window;

            InitializeComponent();

            Dictionary<string, int> tagsSummary = Database.GetTagsSummary(ImageManager.Connection);
            this.tagBox = new TagAutoCompleteTextBox
            {
                Margin = new Thickness(46, 45, 17, 0),
                VerticalAlignment = VerticalAlignment.Top,
                TagsSummary = tagsSummary,
                LimitToOneTag = true
            };

            this.mainGrid.Children.Add(this.tagBox);

            this.titleText.Text = "Editing tags on " + ImageListControl.TotalImages + " images.";
            this.tagBox.TextBox.Focus();
        }

        private void addButton_Click(object sender, RoutedEventArgs e)
        {
            TagOperations.AddTagToVisible(this.tagBox.Text.ToLowerInvariant());
        }

        private void removeButton_Click(object sender, RoutedEventArgs e)
        {
            TagOperations.RemoveTagFromVisible(this.tagBox.Text.ToLowerInvariant());
        }
    }
}
